package com.mkyong.rest;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.mkyong.domain.CabbookingRequest;
import com.mkyong.transaction.CabbookingBo;

@Component
@Path("/admin/cabbooking")
public class CabbookingService {
	
	@Autowired
	CabbookingBo cabbookingBo;
	
	@GET
	@Path("{id}")
	@Produces(MediaType.APPLICATION_JSON)
	public Response getCabbookingReqById(@PathParam("id") String id) throws Exception{
		System.out.println("id "+ id);
		CabbookingRequest request = cabbookingBo.getCabbookingReqById("123896");
		return Response.status(200).entity(request).build();
	}
	
	@POST
	@Path("/add")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	public Response saveCabbookingRequest(CabbookingRequest request)throws Exception{
		System.out.println("From Service: "+request.getDestination());
		System.out.println("From Service: "+request.getOffice());
		request = cabbookingBo.saveCabbookingRequest(request);
		return Response.status(200).entity(request).build();
	}
}
